package com.qf.service.impl;

import com.qf.dao.OrderDetailDao;
import com.qf.dao.impl.OrderDetailDaoImpl;
import com.qf.entity.Goods;
import com.qf.entity.OrderDetail;
import com.qf.service.GoodsService;
import com.qf.service.OrderDetailService;

import java.util.List;

/**
 * @author wgy
 * @version V1.0
 * @project gp12_xiaomi
 * @package com.qf.service.impl
 * @description: ${TODO}
 * @date 2022/6/27 14:29
 */
public class OrderDetailServiceImpl implements OrderDetailService {
    private OrderDetailDao orderDetailDao=new OrderDetailDaoImpl();
    @Override
    public List<OrderDetail> findByOid(String oid) {
        List<OrderDetail> orderDetailList = orderDetailDao.selectByOid(oid);
        if (orderDetailList != null) {
            GoodsService goodsService=new GoodsServiceImpl();
            for (OrderDetail orderDetail : orderDetailList) {
                Integer pid = orderDetail.getPid();
                Goods goods = goodsService.findById(pid);
                orderDetail.setGoods(goods);
            }
        }
        return orderDetailList;
    }
}
